package com.example.loadimage;

import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.resource.bitmap.CenterCrop;
import com.bumptech.glide.load.resource.bitmap.CircleCrop;
import com.bumptech.glide.request.RequestOptions;


public class LoadImage {

    public static void loadMatchImg(String url, ImageView img){
//        Glide.with(img.getContext()).load(url)
//                .placeholder(R.drawable.cutdown_dialog_bg)
//                .error(R.drawable.tt_default_image_error)
//                .transform(new CenterCrop())
//                .into(img);
        Glide.with(img.getContext()).load(url)
                .placeholder(R.drawable.cutdown_dialog_bg)
                .error(R.drawable.tt_default_image_error)
                .transform(new CenterCrop())
                .into(img);
    }

    public static void loadImg(String url,ImageView img){
//        Glide.with(img.getContext()).load(url)
//                .placeholder(R.drawable.cutdown_dialog_bg)
//                .error(R.drawable.tt_default_image_error)
//                .into(img);
        Glide.with(img.getContext()).load(url)
                .placeholder(R.drawable.cutdown_dialog_bg)
                .error(R.drawable.tt_default_image_error)
                .into(img);
    }
    public static void loadCircleImg(String url, ImageView img){
        Glide.with(img.getContext())
                .load(url)
                .error(R.drawable.tt_default_image_error)
                .apply(RequestOptions.bitmapTransform(new CircleCrop()))
                .into(img);
    }

//    public static void loadRoundImg(String url, ImageView img,int radius){
//        Glide.with(img.getContext())
//                .load(BaseConstant.FileUrl+url)
//                // 圆角效果
//                .transform(new CircleCrop(),new RoundedCorners(10))
//                .into(img);
//    }

}
